const Router = require('koa-router');
const router = new Router();
const classController = require('../controllers/class.controller');
const authMiddleware = require('../middlewares/auth.middleware');

// 班级相关API路由

// 获取所有班级列表
router.get('/', authMiddleware.authenticateToken, classController.getAllClasses);

// 获取单个班级信息
router.get('/:id', authMiddleware.authenticateToken, classController.getClassById);

// 创建新班级
router.post('/', authMiddleware.authenticateToken, authMiddleware.authorize(['admin', 'teacher']), classController.createClass);

// 更新班级信息
router.put('/:id', authMiddleware.authenticateToken, authMiddleware.authorize(['admin', 'teacher']), classController.updateClass);

// 删除班级
router.delete('/:id', authMiddleware.authenticateToken, authMiddleware.authorize(['admin']), classController.deleteClass);

// 分页获取班级列表
router.get('/paginated/list', authMiddleware.authenticateToken, classController.getClassesPaginated);

// 根据学院获取班级列表
router.get('/by-academy/:academy', authMiddleware.authenticateToken, classController.getClassesByAcademy);

// 获取班级的学生列表
router.get('/:id/students', authMiddleware.authenticateToken, classController.getClassStudents);

// 获取班级的辅导员信息
router.get('/:id/advisor', authMiddleware.authenticateToken, classController.getClassAdvisor);

module.exports = router;